package com.project.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.StuBean;
import com.project.mapper.IStuMapper;
import com.project.service.IStuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class StuServiceImpl implements IStuService {

    @Autowired
    private IStuMapper mapper;

    @Override
    public PageInfo<StuBean> findByItem(Integer pageNO, String stuName, String className, String roomAddress) {
        PageHelper.startPage(pageNO, 3);
        PageInfo<StuBean> pageInfo = PageInfo.of(mapper.findByItem(stuName, className, roomAddress));
        return pageInfo;
    }

    @Override
    public void addStudent(StuBean student) {
        mapper.addStudent(student);
    }

    @Override
    public void delStudent(Integer stuId) {
        mapper.delStudent(stuId);
    }

    @Override
    public StuBean findById(Integer stuId) {
        return mapper.findById(stuId);
    }

    @Override
    public void updateStuRoom(Integer stuId, Integer roomId) {
        mapper.updateStuRoom(stuId,roomId);
    }
}
